<template>
  <div id="estate">
    <md-field title class="radio-field">
      <md-radio-list v-model="suggestWay" :options="ways" icon-size="lg" />
    </md-field>
    <div class="btn" @click="getUserType">准备好了，下一步</div>
    <h1>业主认证须知</h1>
    <p>1、您要注册业主，请确认您是产权证上的权利人之一；</p>
    <p>2、业主审核，是通过上传业主本人的身份证照片，并且完成银行卡实名认证，方可通过；</p>
    <p>3、房产产权多人共有的，只有其中一位可申请认证业主，由申请者全权代表其他权利人行使业主大会表决权；</p>
    <p>4、其他共有产权人或家属，可由业主帐号分享设定为家属成员，方可登录查看所有小区治理信息；</p>
    <p>5、房屋产权属于法人资产的，请准备法人营业执照和法人代表授权书。</p>
    <p>6、权利人为港澳台或外籍人士的，因无法在线实名验证，还需本人当面签署书面授权，才能完成业主身份认定。</p>
    <p>7、不想用手机端软件表决的业主，依然可在小区内业主大会人工投票点凭身份证投票。</p>
    <md-popup v-model="isPopupShow.center">
      <div class="pop-tip">
        <p>港澳台同胞及外国人，因为无法在线进行实名验证，只可以由业主或持业主授权书的代表到筹备组现场投票！请保持关注i业主，如有系统升级，可实现在线投票，将第一时间通知您，谢谢。</p>
      </div>
    </md-popup>
  </div>
</template>

<script>
import { Toast, Dialog, RadioList,Popup } from "mand-mobile";
import https from "@/https";
import config from "@/config";
export default {
  components: {
    [Dialog.name]: Dialog,
    [RadioList.name]: RadioList,
    [Popup.name]: Popup,
  },
  name: "estate",
  data() {
    return {
      qid: 0,
      uid: 0,
      suggestWay: 0,
      ways: [
        {
          value: 0,
          text: "我是中国公民业主"
        },
        {
          value: 1,
          text: "我是法人业主（公司拥有产权）"
        },
        {
          value: 2,
          text: "我是港澳台或外籍人士"
        }
      ],
      isPopupShow: {},
    };
  },
  methods: {
    saveUserQuarters() {
      let uid = this.uid;
      let qid = this.qid;
      let type = this.suggestWay;
      let params = {
        uid,
        qid,
        type
      };
      https
        .fetchPost(config.saveUserQuarters, params)
        .then(res => {
          if (res.data.code == 1) {
            Toast.succeed("保存成功",1500);
            setTimeout(() => {
              this.$router.replace({
                path: "/index"
              });
            }, 2000);
          } else {
            Toast.failed(res.data.msg, 2000);
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    showPopUp() {
      this.$set(this.isPopupShow, 'center', true)
    },
    getUserType() {
      let type = this.suggestWay;
      if(type == 2){
        this.showPopUp();
        return;
      }
      let _this = this;
      let uid = this.uid;
      let qid = this.qid;
      let params = {
        uid,
        qid,
        type
      };
      https
        .fetchPost(config.getUserType, params)
        .then(res => {
          if (res.data.code == 1) {
            if (res.data.data.status == 1) {
              Dialog.confirm({
                title: '实名认证：' + res.data.data.name,
                content: "您已实名认证，可直接提交，如要认证其他名字，请取消，并用其他微信进行注册！",
                confirmText: "确定",
                onConfirm: () => {
                  _this.saveUserQuarters();
                },
                onCancel: () => {
                }
              });
            } else {
              this.$router.replace({
                path: "/smallEstateIdentity",
                query: { type: type, qid: qid, uid: uid }
              });
            }
          } else {
            Toast.failed(res.data.msg, 2000);
          }
        })
        .catch(err => {
          console.log(err);
        });
    }
  },
  created() {
    let qid = this.$route.query.qid;
    let uid = this.$route.query.uid;
    this.qid = qid;
    this.uid = uid;
  }
};
</script>

<style  lang="scss" scoped>
$themeColor: #444444;
$themeGold: #d7b987;
#estate {
  display: flex;
  flex-direction: column;
  padding: 0 30px 0;
  color: #444444;
  h1 {
    font-size: 30px;
    padding: 20px 0;
    text-align: center;
  }
  p {
    font-size: 26px;
    line-height: 44px;
  }
  .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 300px;
    height: 70px;
    margin: 20px auto 0;
    font-size: 30px;
    color: #fff;
    background: #2f86f6;
    border-radius: 40px;
    margin-bottom: 20px;
  }
  .pop-tip {
    font-size: 28px;
    color: #333;
    width: 500px;
    line-height: 56px;
    background: #fff;
    padding: 40px 30px;
    border-radius: 8px;
  }
}
</style>
